﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WGMClient.HelperClasses
{
    [Serializable]
    public class WGMSettings
    {
        public string LastUsername{get;set;}
        public string LastPassword { get; set; }
        public bool RememberCreds { get; set; }
        public string SystemFontFamily { get; set; }
        public bool ShowContactImages { get; set; }
        public bool ShowMessageTimeStamps { get; set; }
        public global::System.Windows.Media.Color SystemFontColour { get; set; }
        public double SystemFontSize { get; set; }
        public double RetrieveTimerInterval { get; set; }
        public double RefreshtimerInterval { get; set; }
        public bool IsSystemFontBold { get; set; }
        public bool IsSystemFontItalics { get; set; }
        public bool SaveGlobalHistory { get; set; }
        public bool SavePrivateHistory { get; set; }
        public bool ShowOnlinePopup { get; set; }
        public bool ShowOfflinePopup { get; set; }
        public bool ShowNewMessagePopup { get; set; }
        public bool WindowAnimations { get; set; }
        public double LastWindowWidth { get; set; }
        public double LastWindowHeight { get; set; }
        public bool AlwaysOnTop { get; set; }
        public double LastWindowX { get; set; }
        public double LastWindowY { get; set; }
        public double ImagePreviewWidth { get; set; }
        public double ImagePreviewHeight { get; set; }
        public bool ShowImagePreviews { get; set; }
        public HelperClasses.HashtableSerailizable SoundList { get; set; }
        public WGMSettings()
        {
            SoundList = new HashtableSerailizable();
            SystemFontFamily = "Verdana";
            ShowContactImages = true;
            ShowMessageTimeStamps = true;
            SystemFontColour = System.Windows.Media.Colors.DarkGray;
            SystemFontSize = 11;
            RetrieveTimerInterval = 2;
            RefreshtimerInterval = 3;
            IsSystemFontItalics = true;
            WindowAnimations = true;
            LastWindowHeight = 500;
            LastWindowWidth = 900;
            LastWindowX = 100;
            LastWindowY = 100;
            ImagePreviewHeight = 50;
            ImagePreviewWidth = 50;
            ShowImagePreviews = true;
        }

        internal void AddToSoundList(string username, bool playSound)
        {
            if (!SoundList.Keys.Cast<string>().Contains(username))
            {
                SoundList.Add(username, playSound);
            }
        }

        internal void UpdateSoundList(string username, bool playSound)
        {
            if (SoundList.Keys.Cast<string>().Contains(username))
            {
                SoundList[username] = playSound;
            }
            else
            {
                AddToSoundList(username, playSound);
            }
        }
        internal bool HasSound(string username)
        {
            if (SoundList.Keys.Cast<string>().Contains(username))
            {
                return Convert.ToBoolean(SoundList[username]);
            }
            else
            {
                AddToSoundList(username, false);
                return false;
            }
        }
    }
}
